package com.darrenchan

object FuncDemo {
  def hello(name:String):String = {
    s"hello, ${name}"
  }

  def hello2(name:String) = {
    s"hello2, ${name}"
  }

  def add(a:Int, b:Int) = a + b

  def three()= 1 + 2

  def speed(distance: Float, time: Float): Float = {
    distance / time
  }

  def sum(numbers: Int*): Int ={
    var result = 0
    for (number <- numbers) {
      result += number
    }
    result
  }

  def main(args: Array[String]): Unit = {
    println(hello("chenchi"))
    println(hello2("chenchi"))
    println(add(5, 6))
    println(three) // 没有入参的参数，括号可以省略

    println(speed(time = 10, distance = 100))



    println(sum(1, 2))
    println(sum(1, 2, 3))
    println(sum(1, 2, 3, 4))
  }
}
